<?php

namespace common\models\book;

use Yii;

/**
 * This is the model class for table "{{%room_stage}}".
 *
 * @property int $id
 * @property int $room_id 座谈类型ID
 * @property string|null $date 参观日期
 * @property int $start_hour 时段开始时间
 * @property int $end_hour 时段截止时间
 * @property int $status 状态
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class RoomStage extends \common\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%room_stage}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['room_id', 'start_hour', 'end_hour', 'status', 'created_at', 'updated_at'], 'integer'],
            [['date'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'room_id' => '座谈类型ID',
            'date' => '参观日期',
            'start_hour' => '时段开始时间',
            'end_hour' => '时段截止时间',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function getBookStage() {
        return $this->hasOne(BookStage::class, ['room_stage_id' => 'id']);
    }

    /**
     * {@inheritdoc}
     */
    public function getBook() {
        return $this->hasOne(Book::class, ['id' => 'book_id'])->via('bookStage');
    }

}
